package com.lyw.mapper;

import com.lyw.entity.Student;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Mapper
public interface StudentMapper {

  @Select("select id, name, email, age from student")
  List<Student> findStudents();

  @Select("select id, name, email, age from student where name = #{name}")
  Student searchStudent(String name);

  @Insert("insert into student(name, email, age) values(#{name}, #{email}, #{age})")
  //开启主键自增
  @Options(useGeneratedKeys = true, keyProperty = "id")
  Integer insertStudent(Student student);
}
